package com.five.controller.backstage;

import com.five.dao.backstage.OrderManageDao;
import com.five.entity.backstage.TRuzhudetail;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * @Author: 王登峰
 * @Description:
 * @Date: 2020/11/30 22:06
 */
@RestController
@RequestMapping("/orderManage")
public class OrderManageController {
    @Autowired
    OrderManageDao orderManageDao;
    //通过房间类型查找对应的房间
    @RequestMapping("/selectByTID")
    @ResponseBody
    public List<Map> selectByTID(String typeid){
        int i = Integer.parseInt(typeid);
        return orderManageDao.selectByTid(i);
    }
    @RequestMapping("/ruzhudetail")
    @ResponseBody
    public int ruZhuDetail(TRuzhudetail tRuzhudetail){
        int i = orderManageDao.ruZhuDetail(tRuzhudetail);
        if(i > 0){
            orderManageDao.changeStatus(tRuzhudetail.getRoomid());
            return 1;
        }
        else {
            return -1;
        }
    }
    @RequestMapping("/ordercount")
    @ResponseBody
    public int orderCount(String orderid,int num){
        /*System.out.println(orderid+"+++"+num);
        System.out.println(orderManageDao.roomcount(orderid));*/
       return orderManageDao.roomcount(orderid);
    }

}
